Linux Command Line Essentials

Master navigation, file operations, permissions, processes, networking, scripting, and productivity primitives. Focus on composability and the philosophy: small tools, combined power.

📂 FS
🔐 Perms
⚙️ Processes
🌐 Networking
🧩 Pipes
🚀 Productivity

2. Files, Text & Permissions

Manipulate content safely & inspect metadata.

Creation & Inspection

  • touch a.txt create/update timestamp
  • cat file print contents
  • less file page through large content
  • head -n 20, tail -f

Editing

  • nano (simple), vim (modal power), code (VS Code remote)
  • Learn at least basic vim: i insert, :wq write/quit, dd delete line.

Permissions

  • r=4 w=2 x=1; chmod 755 script.sh
  • Symbolic: chmod u+x file
  • Ownership: chown user:group

Finding & Searching

find . -name "*.log" -mtime -1
grep -R "ERROR" logs/
rg pattern src/              # ripgrep (faster)
ag pattern                   # the_silver_searcher
xargs -0 rm < files.txt      # null-safe batch remove
locate config.yaml           # database index

3. Processes & Resource Monitoring

Observe, prioritize & control execution.

Listing

  • ps aux snapshot
  • top dynamic view (htop improved)
  • pgrep nginx PID lookup

Signals

  • kill -TERM pid graceful
  • kill -KILL pid force
  • kill -STOP / -CONT pause/resume

Scheduling

  • cron recurring: crontab -e
  • at 14:30 one-time job
  • nice / renice adjust priority

Background & Foreground

./script.sh &      # run in background
jobs               # list
fg %1              # bring job 1 foreground
nohup long.sh &    # survive hangup
sleep 100 & disown # detach fully

4. Networking & Transfers

Inspect connectivity, latency & move data.

Inspection

  • ip a interfaces
  • ss -tulpen listening sockets
  • dig example.com DNS resolution

Connectivity

  • ping host reachability
  • curl -I https://site headers
  • traceroute host path hops

Transfers

  • scp file user@host:/path
  • rsync -av --progress src/ dest/
  • wget URL download

cURL Patterns

curl -s https://api/service | jq '.items[]'
curl -X POST -H 'Content-Type: application/json' \
  -d '{"name":"demo"}' https://api/service
curl -L -O https://host/file.tar.gz
curl -I https://site --http2

5. Interactive Practice Lab

Simulated shell transformations (no real OS exec here).

Pipe Builder

(analysis)

Permission Calculator

(mode)

Crontab Explainer

(cron meaning)

6. Command Cheat Sheet

High leverage commands grouped by intent.

Compression

tar -czf archive.tgz dir/
zip -r archive.zip dir/
gzip file   # replaces with file.gz
tar -xvf file.tar

Disk & Usage

du -sh *          # folder sizes
ncdu              # interactive usage
df -h             # mounted usage
lsblk             # block devices

Permissions & Identity

id                 # user info
whoami             # current user
umask              # default mask
sudo !!            # repeat prev as root

Networking

nc -zv host 80     # port check
watch -n1 'ss -s'  # socket stats
tcpdump -ni any port 443
ssh -i key.pem user@host

Arch / System

uname -a           # kernel info
lsb_release -a     # distro
lscpu              # CPU details
free -h            # memory

Productivity

history | tail -20
alias gs='git status'
watch -n5 'df -h | grep nvme'
CTRL+R  # reverse search
Principle: Compose simple tools with pipes. If you repeat it twice, automate it (alias, function, script).

7. Mastery Review

Track operational fluency.

Progress Checklist

Concept Q&A

Difference between hard link and soft link?

Hard link points to same inode (same data). Symlink points to path; breaks if target removed. Hard links can't span filesystems or link dirs (usually).

Why use pipes over temp files?

Streams keep data in memory/pipe buffer, reduce I/O, support composability, and encourage single-purpose tools.

What does chmod 750 mean?

User rwx (7), group rx (5), others none (0): only owner executes; group reads/executes.

When prefer rsync over scp?

rsync handles delta transfers, resume, compression, and preserves permissions efficiently; scp always re-copies full files.